import { defineStore } from 'pinia'

export interface PatientInfo {
  id: number
  firstName: string
  lastName: string
  email: string
  mobile: string
  age: string | number
  gender: string
  maritalStatus: string
  bloodGroup: string
  dob: string
  address: string
  suggest: string
}

interface PatientState {
  patients: PatientInfo[]
  currentPatient: PatientInfo | null
}

export const usePatientStore = defineStore('patientStore', {
  state: (): PatientState => ({
    patients: [],
    currentPatient: null,
  }),
  actions: {
    addPatient(data: Omit<PatientInfo, 'id'>) {
      const patient: PatientInfo = {
        id: Date.now(),
        ...data,
      }
      this.patients.unshift(patient)
      this.currentPatient = patient
    },
    setCurrentPatient(patient: PatientInfo | null) {
      this.currentPatient = patient
    },
  },
})
